home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-05-19 | 1.3 KB | 39 lines | [TEXT/ZBAS] |
- 'V
- 'S
- 'GETINDSTRING$ function By Charles Stricklin
- 'Modified by Dave Kelly for MacTutor, May, 1989
-
- 'This function is identical to the procedure GetIndString
- 'which is not in ROM and not supported by ZBasic. It reads
- 'a string from a string list and returns a copy of it in the
- 'variable the String$. If the string list doesn't exist of the
- 'index is out of range an empty string is returned.
-
- ' stringListID is the resource ID of the string list; it's resource type is 'STR#'.
- ' stringIndex is the index of the desired string within the list.
-
- LONG FN GETINDSTRING$(StringListID, StringIndex)
- TheString$=""
- Offset=0
- FALSE=0
- MyHandle&=FN GETRESOURCE(CVI("STR#"),StringListID)
- LONG IF FN RESERROR=FALSE
- MyPointer&=USR 3(MyHandle&)
- NumberOfStrings=PEEK WORD(MyPointer&)
- LONG IF (StringIndex>0) AND (StringIndex <= NumberOfStrings)
- LONG IF StringIndex>1
- FOR ThisString=1 TO StringIndex-1
- LengthOfThisString=PEEK(MyPointer&+2+Offset)
- Offset=Offset+LengthOfThisString+1
- NEXT
- END IF
- LengthOfDesiredString=PEEK(MyPointer&+2+Offset)
- FOR Character=1 TO LengthOfDesiredString
- TheString$=TheString$+CHR$(PEEK(MyPointer&+2+Offset+Character))
- NEXT
- END IF
- MyHandle&=USR 7(MyPointer&)
- CALL DETACHRESOURCE(MyHandle&)
- END IF
- END FN= TheString$
-